home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VERPRNT.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  7KB  |  187 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13.  
  14. DOSSEG
  15. .model medium, Basic
  16.  
  17. .data
  18.     ;external data so all video routines can access
  19.     EVEN
  20.     EXTRN    B$DVIDEOSEG:WORD
  21.     EXTRN   B$DVIDEOPORT:WORD
  22.     EXTRN   B$DVIDEOINSTL:BYTE
  23. .code
  24.  
  25. INCLUDE NOWAIT.INC
  26. EXTRN    Get_Adapter:FAR
  27. EXTRN    SET_DI:FAR
  28.  
  29. ;============================================================================
  30. ; VPRINT.ASM - performs Vertical Printing in the QuickBASIC
  31. ; DECLARE SUB VPRINT (BYVAL ROW%, BYVAL COL%, Text$, BYVAL ATTRIBUTE%)
  32. ; Works in TextMode only, ignores all special characters
  33. ; Sensitive to all video modes (i.e. no snow on CGA's)
  34. ; If no attribute is selected, the default attribute is &H07 (normal)
  35. ; Assumes: Display width is 80 columns
  36. ;============================================================================
  37.  
  38. EVEN
  39. VPRINT Proc FAR BASIC USES SI DI, \
  40. ROW:Ptr, COLL:Ptr, TEXTSTRG:Ptr, ATTRIB:Ptr
  41.  
  42. comment |
  43.      Register usage when all done:
  44.      AH = Color attribute for printing entire string.
  45.      AL = temporarily holds the character to print.
  46.      CX = Length of Text string.
  47.      DX = Port for CGA video retrace check, if necessary.
  48.           0 means display is not a not a CGA display
  49.      DI = Offset of Screen for current character
  50.      ES = Segment of Video display, 0xB000 or 0xB800
  51.      SI = Offset of Text$ String
  52.      DS = Assumed to point to segment containing Text string.
  53.           Program does not set this, so string is assumed to
  54.           be a near string in DGROUP, the default in QB 4.5
  55.      BX = is used as a scratch variable register
  56.      |
  57.  
  58.  
  59.     Cmp   B$DVIDEOINSTL,1 ;See if we have done this before
  60.     JE    Didit        ;yep, so skip ahead
  61.     Call  Get_Adapter  ;call routine to find display type
  62.  
  63. Didit:
  64.     Mov   CX,ROW       ;read value of Row
  65.                ;   allow EGA 43 line/ VGA 50 line
  66.     Dec   CX           ;convert to BIOS format
  67.     Cmp   CX,49        ;check if within range 1 to 50
  68.     JA    Exit         ;exit if too large, or 0
  69.     Mov   DH,CL        ;store ROW (CL) in DH
  70.  
  71.     Mov   CX,COLL      ;read value of COLL
  72.     Dec   CX           ;convert to BIOS format
  73.     Cmp   CX,79        ;check if within range 1 to 80
  74.     JA    Exit         ;exit if too large, or 0
  75.     Mov   DL,CL        ;store COLL (CL) in DL
  76.     CALL SET_DI        ;call routin to find video seg offset in DI
  77.       
  78.     Mov   ES,B$DVIDEOSEG  ;restore the initialized values
  79.     Mov   DX,B$DVIDEOPORT ;puts 0 in DX if not CGA
  80.     Mov   AX,ATTRIB    ;get the color ATTRIBUTE% that was passed
  81.     Mov   AH,AL        ;put it into AH for screen writing below
  82.     Or    AH,AH        ;& make sure attribute is not &H00
  83.     Jnz   @f           ;this is the default if no attribute selected
  84.     Mov   AH,07        ;Default of black background, white letters
  85. @@:
  86.     Mov   SI,TEXTSTRG  ;put descriptor to TEXT$ into SI
  87.     Mov   CX,[SI]      ;put Len(TEXT$) into CX for loop counter
  88.     JCXZ  Exit         ;if CX is zero it's a null string, exit now
  89.     Mov   SI,[SI+02]   ;put address of first character in X$ into SI
  90.     Cld                ;clear the direction flag to move data forward
  91.  
  92. Main_Loop:
  93.     Or    DX,DX        ;are we on a mono or EGA system (is DX = 0)?
  94.     JZ    Mono         ;yes, skip over the retrace stuff
  95.  
  96. EVEN
  97. CGA:
  98.     CLI                ;prevent interrupts to speed routine
  99.     Wait_CGA_Retrace   ;wait for CGA retrace MACRO
  100.     Lodsb              ;get the character from TEXT$ and increment SI
  101.     Stosw              ;store both the character and attribute
  102.     STI                ;allow interrupts again
  103.     Add   DI,158       ;skipping down each row (Stosw already
  104.                ;increments one character)
  105.     Loop  CGA          ;loop until CX is zero
  106.     Jmp  Short  Exit
  107. EVEN
  108. Mono:
  109.     Lodsb              ;get the character from TEXT$ and increment SI
  110.     Stosw              ;store both the character and attribute
  111.     Add   DI,158       ;skipping down each row (Stosw already
  112.                ;increments one character)
  113.     Loop  Mono         ;loop until CX is zero
  114.  
  115. Exit:
  116.     Ret                ;return skipping the passed parameters
  117. VPRINT  Endp
  118.  
  119. ;============================================================================
  120. ; VPRT.ASM - performs Vertical Printing in the QuickBASIC
  121. ; DECLARE SUB VPRT (BYVAL ROW%, BYVAL COL%, TEXT$)
  122. ; Works in TextMode only, ignores all special characters
  123. ; Sensitive to all video modes (i.e. no snow on CGA's)
  124. ; Does not change the attribute, uses whatever was there.
  125. ; Assumes: Display width is 80 columns
  126. ;============================================================================
  127.  
  128. EVEN
  129. VPRT Proc FAR BASIC USES SI DI, \
  130. ROW:Ptr, COLL:Ptr, TEXTSTRG:Ptr,
  131.  
  132.     Cmp   B$DVIDEOINSTL,1 ;See if we have done this before
  133.     JE    Didit1       ;yep, so skip ahead
  134.     Call  Get_Adapter  ;call routine to find display type
  135.  
  136. Didit1:
  137.     Mov   CX,ROW       ;read value of ROW
  138.                ;--allow EGA 43 line/ VGA 50 line
  139.     Dec   CX           ;convert to BIOS format, 0 wd become &HFFFF
  140.     Cmp   CX,49        ;check if within range 1 to 50
  141.     JA    Exit1        ;exit if too large
  142.     Mov   DH,CL        ;store CL in DH
  143.  
  144.     Mov   CX,COLL      ;read value of COLL
  145.     Dec   CX           ;convert to BIOS format, a 0 wd become &HFFFF
  146.     Cmp   CX,79        ;check if within range 1 to 80,
  147.     JA    Exit1        ;exit if too large, exit if >80 or = 0
  148.     Mov   DL,CL        ;store CL in DL
  149.  
  150.     CALL SET_DI        ;call routine to find video seg offset in DI
  151.  
  152.     Mov   ES,B$DVIDEOSEG  ;restore the initialized values
  153.     Mov   DX,B$DVIDEOPORT ;DX = 0 if not CGA, else CGA retrace port
  154.  
  155.     Mov   SI,TEXTSTRG  ;put descriptor to TEXT$ into SI
  156.     Mov   CX,[SI]      ;put Len(TEXT$) into CX for loop counter
  157.     JCXZ  Exit1        ;if CX is zero it's a null string, exit now
  158.     Mov   SI,[SI+02]   ;put address of first character in X$ into SI
  159.     Cld                ;clear the direction flag to move data forward
  160.  
  161. Main_Loop1:
  162.     OR    DX,DX        ;are we on a mono or EGA system (is DX = 0)?
  163.     JZ    Mono1        ;yes, skip over the retrace stuff
  164.  
  165. EVEN               ; speeds loop
  166. CGA1:
  167.     CLI                ;prevent interrupts to speed routine
  168.     Wait_CGA_Retrace   ;wait for CGA retrace MACRO
  169.     Lodsb              ;get the character from TEXT$ and increment SI
  170.     Stosb              ;store just the character but not the attribute
  171.     STI                ;allow interrupts again
  172.     Add   DI,159       ;skipping down each row
  173.     Loop  CGA1         ;loop until CX is zero
  174.     Jmp   Short  Exit1
  175.  
  176. EVEN               ; speeds loop
  177. Mono1:
  178.     Lodsb              ;get the character from TEXT$ and increment SI
  179.     Stosb              ;store just the character but not the attribute
  180.     Add    DI,159      ;skipping down each row
  181.     Loop   Mono1       ;loop until CX is zero
  182.  
  183. Exit1:
  184.     Ret                ;return skipping the passed parameters
  185. VPRT    Endp
  186. END
  187.